package com.lingyuan.oms.factory;

import com.lingyuan.oms.constant.HandlerType;
import com.lingyuan.oms.handler.Handler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

/**
 * @ClassName：HandlerFactory
 * @Author: LeiHao
 * @Date: 2024/10/8 10:22
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Service
public class HandlerFactory {
    private ApplicationContext context;

    @Autowired
    public HandlerFactory(ApplicationContext context) {
        this.context = context;
    }

    public Handler getHandler(HandlerType type) {
        return context.getBean(type.getHandlerName(), Handler.class);
    }
}
